<?php
error_reporting(0);
include("filter.php");
header('Content-type:text/json;charset=utf-8');     //这句是重点，它告诉接收数据的对象此页面输出的是json数据；
echo "&";
$name = $_GET['name'];
$totilKilled = $_GET['totilKilled'];
$maxOnceKilled = $_GET['maxOnceKilled'];
$level = $_GET['level'];
$lastTime = $_GET['lastTime'];
$updatetime = date('Y-m-d H:i:s');
$name = filter($name);
$totilKilled = filter($totilKilled);
$maxOnceKilled = filter($maxOnceKilled);
$level = filter($level);
$lastTime = filter($lastTime);
if(empty($name) || empty($totilKilled) || empty($maxOnceKilled) || empty($level) || empty($lastTime)){
    die('Need More Information&');
    echo "&";
}
$mysqli = new mysqli('localhost', 'GameServer', 'J8TED4Ks3CPkAdHY', 'gameserver');

if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno .''. $mysqli->connect_error);
    echo "&";
}

$sql = "REPLACE INTO `data` (`id`, `totilKilled`, `maxOnceKilled`, `level`, `lastTime`, `updatetime`) VALUES ('".$name."', '".$totilKilled."', '".$maxOnceKilled."', '".$level."', '".$lastTime."', '".$updatetime."')";
if ($mysqli->query($sql) === TRUE) {
    echo 'OK';
} else {
    echo "Error: ". $mysqli->error;
}
echo "&";
?>